package com.lhnstart.learn.bases.dynamic_;

/**
 * 动态绑定机制
 *
 * @author lhn
 * @date 2023/06/07 11:01
 * @since 1.0.0
 **/
public class DynamicBind {

    public static void main(String[] args) {
        // A 编译类型 B 运行类型
        A a = new B();
        B B = new B();
        System.out.println(a.sum());
        System.out.println(a.sum1());
        boolean equals = a.equals(B);
    }


}

class A{
    public int i = 10;

    public int sum() {
        return getI() + 10;
    }

    public int sum1() {
        return i + 10;
    }

    public int getI() {
        return i;
    }
}

class B extends A{
    public int i = 20;

    //public int sum() {
    //    return i + 20;
    //}

    public int getI() {
        return i;
    }

    //public int sum1() {
    //    return i + 10;
    //}
}